<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑论文</title>
    <#include "layout/import_js.ftl" />
    <#include "layout/import_css.ftl" />
    <script>
        $(() => {
            $("#edit-thesis").on('click', function () {
                let form = new FormData(document.getElementById("form-thesis"));
                $.ajax({
                    url: '/thesis/edit',
                    method: 'post',
                    data: form,
                    processData: false, //禁止序列化data，默认为true
                    contentType: false, //避免JQuery对contentType做操作
                    success: function (res) {
                        if (res.code == 0) {
                            $('#alertModal').modal('show')
                        } else {
                            console.log(res);
                        }
                    },
                    error: function (err) {
                        console.log(err);
                    }
                })
            })
        })
    </script>
</head>
<body>
<#include "layout/header.ftl"/>
<#include "layout/sidebar.ftl"/>

<div class="container">
    <div class="raw">
        <div class="col-sm-6 col-sm-offset-3">
            <form action="/thesis/edit" id="form-thesis" method="POST" enctype="multipart/form-data"
                  class="form-horizontal">
                <input type="hidden" name="id" value="${entity.id}">
                <div class="form-group">
                    <label>名称</label>
                    <input type="text" class="form-control" value="${entity.name}" name="name" placeholder=" ">
                </div>
                <div class="form-group">
                    <label>摘要</label>
                    <textarea name="summary" class="form-control" rows="6">${entity.summary}</textarea>
                </div>
                <div class="form-group">
                    <label>作者</label>
                    <input type="text" class="form-control" value="${entity.authors}" name="authors" placeholder=" ">
                </div>
                <div class="form-group">
                    <label>导师</label>
                    <input type="text" class="form-control" value="${entity.mentors}" name="mentors" placeholder=" ">
                </div>
                <div class="form-group">
                    <label>状态</label>
                    <div>
                        <label class="radio-inline">
                            <input type="radio" name="status" <#if entity.status == 0> checked </#if> value="0"> 审核中
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="status" <#if entity
                            .status == 1> checked </#if> value="1"> 审核通过
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label>发表日期</label>
                    <input type="date" class="form-control" value="${entity.publishDate?string('yyyy-MM-dd')}"
                           name="publishDate">
                </div>
                <div class="form-group">
                    <label>编号</label>
                    <input type="text" class="form-control" value="${entity.number}" name="number" placeholder=" ">
                </div>
                <div class="form-group jumbotron">
                    <label>论文类型</label>
                    <select name="thesisTypeId" class="form-control">
                        <#list thesisTypes as i>
                            <#if (entity.thesisTypeId!-1) == i.id>
                                <option selected value="${i.id!}">${i.name!}</option>
                            <#else>
                                <option value="${i.id!}">${i.name!}</option>
                            </#if>

                        </#list>
                    </select>
                    <label for="">编号</label>
                    <input type="text" class="form-control" name="thesisTypeNumber" value="${entity.thesisTypeNumber!}"
                           placeholder="">
                </div>
                <div class="form-group jumbotron">
                    <label>论文发表类型</label>
                    <select name="thesisPublishTypeId" class="form-control">
                        <#list thesisPublishTypes as i>
                            <#if (entity.thesisPublishTypeId!-1) == i.id>
                                <option selected value="${i.id!}">${i.name!}</option>
                            <#else>
                                <option value="${i.id!}">${i.name!}</option>
                            </#if>

                        </#list>
                    </select>
                    <label for="">发表类型名</label>
                    <input type="text" class="form-control" name="thesisPublishTypeContent" value="${entity
                    .thesisPublishTypeContent!}"
                           placeholder="">
                </div>
                <div class="form-group">
                    <label for="exampleInputFile">上传文件</label>
                    <div>
                        当前文件:
                        <a href="/upload-attachments/theses/${entity.attachment?default('')}">${entity.attachment?default('--')}</a>
                    </div>
                    <input type="file" name="file" id="attachment" accept=".jpg,
                    .jpeg,.png,.doc,
                    .docx,.pdf,
                    .ppt,.pptx,.xlsx">
                    <input type="hidden" name="attachment" value="${entity.attachment?default('--')}">
                    <p class="help-block">支持pdf、word、excel、png、jpeg等类型</p>
                </div>

                <div class="form-group">
                    <div class="col-sm-6 col-sm-offset-3">
                        <button type="button" class="btn btn-success" id="edit-thesis">更新
                        </button>
                        <a href="/thesis" class="btn btn-info">取消</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<#include "layout/alert.ftl"/>
<#include "layout/footer.ftl"/>
</body>
</html>